|
|
|
| Table 9.6 Codes for Defining Numeric Formats | | Symbol | Purpose | Meaning | | 0 | Digit placeholder | Displays the digit or displays 0 if no digit appears in that location. | | # | Digit placeholder | Displays the digit or displays nothing if no digit appears in that location. This causes leading and trailing zeros to be omitted. | | . | Decimal separator | Indicates where the decimal point is displayed. | | , | Thousands separator | Indicates where the separators are displayed. | | % | Percentage indicator | Indicates where a percent sign is displayed. Also causes the number to be multiplied by 100. | | E-, E+, e-, e+ | Scientific Notation | Using E- or e- displays a minus sign next to negative exponents but displays no sign for positive exponents. Using E+ or e+ displays a sign for any exponent. |
|
|
|
|
|
|
Another form of data that is often a chore to print is dates. If you specify the Print method with a date, it is displayed in the default format for your systemtypically something like 7/5/98. If you want to display the date in another manner (for example, July 5, 1998), you need to use the Format function. Table 9.7 lists some predefined date and time formats (see Figure 9.7). |
|
|
|
|
| Table 9.7 Named Date and Time Formats | | Named Format | Description | | General Date | Shows the date and time if the expression contains both portions. Otherwise, displays either the date or the time. | | Long Date | Prints the day of the week, the day of the month, the month, and the year. | | Medium Date | Prints the day of the month, a three-letter abbreviation for the month, and the year. | | Short Date | Prints the day, month, and yearfor example, 7/5/98. | | Long Time | Print hours, minutes, and seconds along with the AM/PM indication. | | Medium Time | Prints hours and minutes along with AM or PM. | | Short Time | Prints hours and minutes in military time. |
|
|
|
|
|
|
In addition to the named values in Table 9.7, there are many codes available that you can use to create your own date and time formats. For example, the following line of code prints today's date on the form: |
|
|
|
|
|
|
|
|
Form1.print Format(Now,"mm/dd/yyyy") |
|
|
|
|
|